package com.xjoyt.pay.master.po;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.xjoyt.pay.constants.DateConstant;

/**
 * 上游通道
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_channel")
public class Channel {

	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	@Column(name = "channel_id", length = 36)
	public String id;

	/**
	 * 通道编号
	 */
	@Column(name = "channel_no", length = 50)
	public String no;

	/**
	 * 通道名称
	 */
	@Column(name = "channel_name", length = 50)
	public String name;

	/**
	 * 权重(优先级别)
	 */
	@Column(name = "`weight`")
	public Integer weight;

	/**
	 * 支付接口
	 */
	@OneToMany(targetEntity = PayChannel.class, cascade = { CascadeType.REMOVE })
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "none"))
	// @JsonIgnore
	public List<PayChannel> channels;

	/**
	 * 机构通道
	 */
	@OneToMany(targetEntity = CompanyChannel.class, cascade = { CascadeType.REMOVE })
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public List<CompanyChannel> companyChannels;

	/**
	 * 适配器进件接口URL
	 */
	@Column(name = "register_url", length = 255)
	public String registerUrl;

	/**
	 * 适配器提现接口URL
	 */
	@Column(name = "cash_url", length = 255)
	public String cashUrl;

	/**
	 * 提现费率(%)
	 */
	@Column(name = "cash_rate")
	public Double cashRate;

	/**
	 * 提现固定手续费(%)
	 */
	@Column(name = "cash_money")
	public Long cashMoney;

	/**
	 * 提现上限手续费(%)
	 */
	@Column(name = "cash_limit")
	public Long cashLimit;

	/**
	 * 提现下限手续费(%)
	 */
	@Column(name = "cash_minimum")
	public Long cashMinimum;

	/**
	 * 适配器自动对账地址
	 */
	@Column(name = "check_url", length = 255)
	public String checkUrl;

	/**
	 * 适配器退款地址
	 */
	@Column(name = "refund_url", length = 255)
	public String refundUrl;

	/**
	 * 健康状体监控URL
	 */
	@Column(name = "health_url", length = 255)
	public String healthUrl;

	/**
	 * 是否开启健康监测
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_health_enabled")
	public Boolean healthEnabled;

	/**
	 * 适配器退款回调地址
	 */
	@Column(name = "refund_callback_url", length = 255)
	public String refundCallbackUrl;

	/**
	 * 公司
	 */
	@ManyToOne(targetEntity = Company.class, cascade = {})
	@JoinColumn(name = "company_id", foreignKey = @ForeignKey(name = "none"))
	// @JsonIgnore
	public Company company;

	/**
	 * 是否开启
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_enabled")
	public Boolean enabled;

	/**
	 * 录入日期
	 */
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "added_date")
	@JsonFormat(pattern = DateConstant.DATE_TIME_FORMAT_PATTERN, timezone = "GMT+8")
	public Date addedDate;

	/**
	 * 开户人姓名
	 */
	@Column(name = "card_name", length = 50)
	public String cardName;

	/**
	 * 卡号
	 */
	@Column(name = "card_no", length = 50)
	public String cardNo;

	/**
	 * 大行名称
	 */
	@Column(name = "bank_name", length = 50)
	public String bankName;

	/**
	 * 大行号
	 */
	@Column(name = "bank_no", length = 50)
	public String bankNo;

	/**
	 * 联行号
	 */
	@Column(name = "bank_code", length = 50)
	public String bankCode;

	/**
	 * 开户行名称
	 */
	@Column(name = "bank", length = 50)
	public String bank;

	/**
	 * 开户行地址
	 */
	@Column(name = "bank_address", length = 50)
	public String bankAddress;

	/**
	 * 适配器代付接口URL
	 */
	@Column(name = "pay_url", length = 255)
	public String payUrl;

	/**
	 * 是否开启代付
	 */
	@org.hibernate.annotations.Type(type = "yes_no")
	@Column(name = "is_pay_enabled")
	public Boolean payEnabled;
	
	/**
	 * 代付费率(%)
	 */
	@Column(name = "pay_rate")
	public Double payRate;

	/**
	 * 代付固定手续费(%)
	 */
	@Column(name = "pay_money")
	public Long payMoney;

	/**
	 * 代付上限手续费(%)
	 */
	@Column(name = "pay_limit")
	public Long payLimit;

	/**
	 * 代付下限手续费(%)
	 */
	@Column(name = "pay_minimum")
	public Long payMinimum;

}
